﻿using System;

namespace Zocono.WCS.Infrastructure.Device
{

	/// <summary>
	/// 设备接口
	/// </summary>
	public interface IDevice
	{
		/// <summary>
		/// 设备初始化
		/// </summary>
		void Init();

		/// <summary>
		/// 设备启动
		/// </summary>
		void Start();

		/// <summary>
		/// 设备停止
		/// </summary>
		void Stop();

		/// <summary>
		/// 设备释放
		/// </summary>
		void Release();


		/// <summary>
		/// 设备ID
		/// </summary>
		int DeviceID { get; }


		/// <summary>
		/// 设备类型
		/// </summary>
		string DeviceType { get; }

		/// <summary>
		/// 设备备注
		/// </summary>
		/// <returns></returns>
		string ToString();

	}


	/// <summary>
	/// 设备基类
	/// </summary>
	public abstract class Device : IDevice
	{
		public Device() { }

		/// <summary>
		/// 初始化
		/// </summary>
		public void Init()
		{

			// Log.Runlog.Instance.Add(this.ToString(), "Init");
			DoInit();
		}
		/// <summary>
		/// 启动
		/// </summary>
		public void Start()
		{
			//Log.Runlog.Instance.Add(this.ToString(), "Start");
			DoStart();
		}
		/// <summary>
		/// 停止
		/// </summary>
		public void Stop()
		{
			//Log.Runlog.Instance.Add(this.ToString(), "Stop");
			DoStop();
		}
		/// <summary>
		/// 释放
		/// </summary>
		public void Release()
		{
			// Log.Runlog.Instance.Add(this.ToString(), "Release");
			DoRelease();
		}

		/// <summary>
		/// 设备ID
		/// </summary>
		public virtual int DeviceID
		{
			get { return 0; }
		}


		/// <summary>
		/// 初始化钩子函数
		/// </summary>
		public abstract void DoInit();
		/// <summary>
		/// 启动钩子函数
		/// </summary>
		public abstract void DoStart();
		/// <summary>
		/// 停止钩子函数
		/// </summary>
		public abstract void DoStop();
		/// <summary>
		/// 释放钩子函数
		/// </summary>
		public abstract void DoRelease();
		/// <summary>
		/// 设备类型
		/// </summary>
		public abstract string DeviceType { get; }


		/// <summary>
		/// ToString
		/// </summary>
		/// <returns></returns>
		public abstract override string ToString();


	}
}
